<template>
  <div class="tab-menu">
    <div class="menu-list">
      <div
        class="menu-list-item"
        v-for="(item, index) in datalist"
        :key="index"
        :class="{ clickclass: current === index }"
        @click="itemClick(index)"
      >
        {{ item.title }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  // name: TabMenu,
  props: {
    datalist: {
      type: Array,
      defalut() {
        return [];
      },
    },
  },
  data() {
    return {
      current: 0,
    };
  },
  methods: {
    itemClick(index) {
      this.current = index;
      console.log(index);
      this.$emit("itemClick", index);
    },
  },
};
</script>

<style scoped>
.tab-menu {
  background-color: #f6f6f6;
  box-sizing: border-box;
  position: relative;
  top: 0;
  left: 0;
}
.menu-list-item {
  height: 8vh;
  line-height: 8vh;
  text-align: center;
  font-size: 14px;
}
.clickclass {
  background-color: #fff;
  color: #ff5777;
  border-left: 2px solid #ff5777;
  border-right: 0;
}
</style>